package shuati.meituan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @author : LdLtd
 * @Date : 2024/4/6
 * @Description:
 */
public class c030903 {
    public static void main(String[] args) throws IOException {
//        StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        in.nextToken();int n=(int)in.nval;
//        in.nextToken();int q=(int)in.nval;
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        in.nextToken();int n = (int) in.nval;
        in.nextToken();int k = (int) in.nval;
        in.nextToken();String string = in.sval;
        int sum = 0;
        for(int i = 0;i<string.length();i++){
            if(string.charAt(i)=='M'||string.charAt(i)=='T'){
                sum++;
            }
        }
        System.out.println(sum+k>=n?n:sum+k);

    }
}
